/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CustomerSearchCondition;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class DeleteCustomerShare extends AbstractAction
/*    */ {
/* 25 */   private static Logger logger = Logger.getLogger(DeleteCustomerShare.class
/* 26 */     .getName());
/*    */ 
/*    */   public DeleteCustomerShare(AbstractHttpServlet servlet)
/*    */   {
/* 29 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 36 */     User loginUser = getLoginUser(request);
/* 37 */     response.setContentType("text/html;charset=utf-8");
/* 38 */     PrintWriter out = response.getWriter();
/* 39 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 41 */     String customerIds = Util.getURLParameter(request
/* 42 */       .getParameter("CustomerIds"));
/*    */ 
/* 44 */     String selectAll = Util.getURLParameter(request
/* 45 */       .getParameter("selectAll"));
/*    */ 
/* 48 */     if ("1".equals(selectAll)) {
/* 49 */       CustomerSearchCondition searchCondition = new CustomerSearchCondition(
/* 50 */         request, loginUser, false);
/*    */ 
/* 52 */       CustomerManager manager = new CustomerManager();
/* 53 */       int result = manager.removeShareSelectAll(searchCondition, 
/* 54 */         loginUser);
/* 55 */       jsonObject.put("error", "0");
/* 56 */       jsonObject.put("removeShareNum", Integer.valueOf(result));
/* 57 */       out.println(jsonObject);
/* 58 */       out.flush();
/* 59 */       out.close();
/* 60 */       return;
/*    */     }
/*    */ 
/* 64 */     if ((customerIds == null) || (customerIds.trim().length() == 0)) {
/* 65 */       jsonObject.put("error", "1");
/* 66 */       out.println(jsonObject);
/* 67 */       out.flush();
/* 68 */       out.close();
/* 69 */       return;
/*    */     }
/* 71 */     CustomerManager manager = new CustomerManager();
/* 72 */     int deleteNum = 0;
/*    */     try {
/* 74 */       deleteNum = manager.removeShare(customerIds, loginUser.userId);
/*    */     } catch (DBException e) {
/* 76 */       logger.warn("remove share failed", e);
/*    */     }
/* 78 */     jsonObject.put("error", "0");
/* 79 */     jsonObject.put("removeShareNum", Integer.valueOf(deleteNum));
/* 80 */     out.println(jsonObject);
/* 81 */     out.flush();
/* 82 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.DeleteCustomerShare
 * JD-Core Version:    0.6.1
 */